import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

export type PageResult = {
  success: boolean;
  data: {
    type?: number; //返回额外的选择题型用于展示
    title?: string; //返回额外的题目用于展示
    /** 列表数据 */
    list: Array<any>;
    /** 总数 */
    total?: number;
  };
  errMsg: "";
};

export type DataResult = {
  success: boolean;
  data?: {};
  errMsg: "";
};

export type PaperExtResult = {
  success: boolean;
  scoreList?: { type0: number; type1: number; type2: number; type3: number };
  questionList?: [];
  errMsg: "";
};

export type StatisticsResult = {
  success: boolean;
  data?: [];
  errMsg: "";
};

export type PhotoResult = {
  success: boolean;
  photo?: string;
  errMsg: "";
};

/////////模拟题库管理//////////

export const querySimulatorQuestionList = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("querySimulatorQuestionList"),
    {
      data
    }
  );
};

export const addOrUpdateSimulatorQuestion = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("addOrUpdateSimulatorQuestion"),
    {
      data
    }
  );
};

export const deleteSimulatorQuestion = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("deleteSimulatorQuestion"),
    {
      data
    }
  );
};

export const querySimulatorQuestionChildList = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("querySimulatorQuestionChildList"),
    {
      data
    }
  );
};

export const uploadSimulatorExcel = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("uploadSimulatorExcel"), {
    data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

export const querySimulatorQuestionChoiceList = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("querySimulatorQuestionChoiceList"),
    {
      data
    }
  );
};

export const addOrUpdateSimulatorQuestionChoice = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("addOrUpdateSimulatorQuestionChoice"),
    {
      data
    }
  );
};

export const deleteSimulatorQuestionChoice = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("deleteSimulatorQuestionChoice"),
    {
      data
    }
  );
};

///////正式题库管理///////

export const queryProduceQuestionList = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("queryProduceQuestionList"),
    {
      data
    }
  );
};

export const addOrUpdateProduceQuestion = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("addOrUpdateProduceQuestion"),
    {
      data
    }
  );
};

export const deleteProduceQuestion = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteProduceQuestion"), {
    data
  });
};

export const queryProduceQuestionChildList = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("queryProduceQuestionChildList"),
    {
      data
    }
  );
};

export const uploadProduceExcel = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("uploadProduceExcel"), {
    data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

export const queryProduceQuestionChoiceList = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("queryProduceQuestionChoiceList"),
    {
      data
    }
  );
};

export const addOrUpdateProduceQuestionChoice = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("addOrUpdateProduceQuestionChoice"),
    {
      data
    }
  );
};

export const deleteProduceQuestionChoice = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("deleteProduceQuestionChoice"),
    {
      data
    }
  );
};

export const queryProduceExamByTask = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("queryProduceExamByTask"),
    {
      data
    }
  );
};

export const takePhoto = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("takePhoto"), {
    data
  });
};

export const expelExam = (data?: object) => {
  return http.request<PhotoResult>("post", baseUrlApi("expelExam"), {
    data
  });
};

export const getPhotoList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("getPhotoList"), {
    data
  });
};

///////学员管理///////

export const queryStudentList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryStudentList"), {
    data
  });
};

export const updateStudentStatus = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("updateStudentStatus"), {
    data
  });
};

export const addOrUpdateStudent = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("addOrUpdateStudent"), {
    data
  });
};

export const deleteStudent = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteStudent"), {
    data
  });
};
/////考试试卷管理//////////

export const queryProducePaperList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryProducePaperList"), {
    data
  });
};

export const updateProducePaperStatus = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("updateProducePaperStatus"),
    {
      data
    }
  );
};

export const addOrUpdateProducePaper = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("addOrUpdateProducePaper"),
    {
      data
    }
  );
};

export const deleteProducePaper = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteProducePaper"), {
    data
  });
};

export const queryProducePaperExtByPaper = (data?: object) => {
  return http.request<PaperExtResult>(
    "post",
    baseUrlApi("queryProducePaperExtByPaper"),
    {
      data
    }
  );
};

export const queryProduceQuestionByType = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("queryProduceQuestionByType"),
    {
      data
    }
  );
};

/////发布考试任务//////////

export const queryProduceTaskList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryProduceTaskList"), {
    data
  });
};

export const updateProduceTaskStatus = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("updateProduceTaskStatus"),
    {
      data
    }
  );
};

export const addOrUpdateProduceTask = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("addOrUpdateProduceTask"),
    {
      data
    }
  );
};

export const deleteProduceTask = (data?: object) => {
  return http.request<DataResult>("post", baseUrlApi("deleteProduceTask"), {
    data
  });
};

export const queryProducePaperAllList = (data?: object) => {
  return http.request<PageResult>(
    "post",
    baseUrlApi("queryProducePaperAllList"),
    {
      data
    }
  );
};

export const queryExamLoggerList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryExamLoggerList"), {
    data
  });
};

export const queryProduceExamList = (data?: object) => {
  return http.request<PageResult>("post", baseUrlApi("queryProduceExamList"), {
    data
  });
};

export const getDistributionExamScores = (data?: object) => {
  return http.request<StatisticsResult>(
    "post",
    baseUrlApi("getDistributionExamScores"),
    {
      data
    }
  );
};
//////////学员菜单管理////////

export const queryStudentRouterList = () => {
  return http.request<PageResult>("get", baseUrlApi("queryStudentRouterList"));
};

export const updateStudentRouterStatus = (data?: object) => {
  return http.request<DataResult>(
    "post",
    baseUrlApi("updateStudentRouterStatus"),
    {
      data
    }
  );
};
